<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDBusPendingCallWatcher Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDBusPendingCallWatcher Class Reference<br /><sup><sup>[<a href="qtdbus.html">QtDBus</a> module]</sup></sup></h1><p>The QDBusPendingCallWatcher class provides a convenient way for
waiting for asynchronous replies <a href="#details">More...</a></p>

<p>Inherits <a href="qobject.html">QObject</a> and <a href="qdbuspendingcall.html">QDBusPendingCall</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdbuspendingcallwatcher.html#QDBusPendingCallWatcher">__init__</a></b> (<i>self</i>, QDBusPendingCall&#160;<i>call</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />bool <b><a href="qdbuspendingcallwatcher.html#isFinished">isFinished</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdbuspendingcallwatcher.html#waitForFinished">waitForFinished</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qdbuspendingcallwatcher.html#finished">finished</a></b> (QDBusPendingCallWatcher *)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDBusPendingCallWatcher class provides a convenient way for
waiting for asynchronous replies</p>
<p>The QDBusPendingCallWatcher provides the <a href="qdbuspendingcallwatcher.html#finished">finished</a>() signal that
will be emitted when a reply arrives.</p>
<p>It is usually used like the following example:</p>
<pre class="cpp">
     <span class="type"><a href="qdbuspendingcall.html">QDBusPendingCall</a></span> async <span class="operator">=</span> iface<span class="operator">-</span><span class="operator">&gt;</span>asyncCall(<span class="string">"RemoteMethod"</span><span class="operator">,</span> value1<span class="operator">,</span> value2);
     <span class="type">QDBusPendingCallWatcher</span> <span class="operator">*</span>watcher <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QDBusPendingCallWatcher</span>(async<span class="operator">,</span> <span class="keyword">this</span>);

     <span class="type"><a href="qobject.html">QObject</a></span><span class="operator">.</span>connect(watcher<span class="operator">,</span> SIGNAL(finished(<span class="type">QDBusPendingCallWatcher</span><span class="operator">*</span>))<span class="operator">,</span>
                      <span class="keyword">this</span><span class="operator">,</span> SLOT(callFinishedSlot(<span class="type">QDBusPendingCallWatcher</span><span class="operator">*</span>)));
</pre>
<p>Note that it is not necessary to keep the original <a href="qdbuspendingcall.html">QDBusPendingCall</a> object around since
QDBusPendingCallWatcher inherits from that class too.</p>
<p>The slot connected to by the above code could be something
similar to the following:</p>
<pre class="cpp">
 <span class="type">void</span> MyClass<span class="operator">.</span>callFinishedSlot(<span class="type">QDBusPendingCallWatcher</span> <span class="operator">*</span>call)
 {
     <span class="type"><a href="qdbuspendingreply.html">QDBusPendingReply</a></span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="type"><a href="qbytearray.html">QByteArray</a></span><span class="operator">&gt;</span> reply <span class="operator">=</span> <span class="operator">*</span>call;
     <span class="keyword">if</span> (reply<span class="operator">.</span>isError()) {
         showError();
     } <span class="keyword">else</span> {
         <span class="type"><a href="qstring.html">QString</a></span> text <span class="operator">=</span> reply<span class="operator">.</span>argumentAt<span class="operator">&lt;</span><span class="number">0</span><span class="operator">&gt;</span>();
         <span class="type"><a href="qbytearray.html">QByteArray</a></span> data <span class="operator">=</span> reply<span class="operator">.</span>argumentAt<span class="operator">&lt;</span><span class="number">1</span><span class="operator">&gt;</span>();
         showReply(text<span class="operator">,</span> data);
     }
     call<span class="operator">-</span><span class="operator">&gt;</span>deleteLater();
 }
</pre>
<p>Note the use of <a href="qdbuspendingreply.html">QDBusPendingReply</a> to validate the
argument types in the reply. If the reply did not contain exactly
two arguments (one string and one <a href="qbytearray.html">QByteArray</a>), <a href="qdbuspendingreply.html#isError">QDBusPendingReply.isError</a>()
will return true.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDBusPendingCallWatcher" />QDBusPendingCallWatcher.__init__ (<i>self</i>, <a href="qdbuspendingcall.html">QDBusPendingCall</a>&#160;<i>call</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Creates a <a href="qdbuspendingcallwatcher.html">QDBusPendingCallWatcher</a> object
to watch for replies on the asynchronous pending call <i>call</i>
and sets this object's parent to <i>parent</i>.</p>


<h3 class="fn"><a name="isFinished" />bool QDBusPendingCallWatcher.isFinished (<i>self</i>)</h3><p>Returns true if the pending call has finished processing and the
reply has been received.</p>
<p>Note that this function only changes state if you call <a href="qdbuspendingcallwatcher.html#waitForFinished">waitForFinished</a>()
or if an external D-Bus event happens, which in general only
happens if you return to the event loop execution.</p>
<p><b>See also</b> <a href="qdbuspendingreply.html#isFinished">QDBusPendingReply.isFinished</a>().</p>


<h3 class="fn"><a name="waitForFinished" />QDBusPendingCallWatcher.waitForFinished (<i>self</i>)</h3><p>Suspends the execution of the calling thread until the reply is
received and processed. After this function returns, <a href="qdbuspendingcallwatcher.html#isFinished">isFinished</a>() should
return true, indicating the reply's contents are ready to be
processed.</p>
<p><b>See also</b> <a href="qdbuspendingreply.html#waitForFinished">QDBusPendingReply.waitForFinished</a>().</p>
<hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="finished" />void finished (QDBusPendingCallWatcher *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the pending call has finished and
its reply is available. The <i>self</i> parameter is a pointer to
the object itself, passed for convenience so that the slot can
access the properties and determine the contents of the reply.</p>


<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>